/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 *

package net.worlds.type;

import java.util.Random;
import net.worlds.BuildismException;


public class Color1 {
    private int r;
    private int g;
    private int b;
    private java.awt.Color javaColor;
    public Color1(int r, int g, int b)
    {
        this.r = r;
        this.g = g;
        this.b = b;
        javaColor = new java.awt.Color(r, g, b);
    }
    public Color1(java.awt.Color c)
    {
        r = c.getRed();
        g = c.getGreen();
        b = c.getBlue();
        javaColor = c;
    }
    public Color1(String s)
    {
        //this should already be validated
        String[] parts = s.split(",");
        r = Integer.parseInt(parts[0]);
        g = Integer.parseInt(parts[1]);
        b = Integer.parseInt(parts[2]);
        javaColor = new java.awt.Color(r, g, b);
    }
    public Color1 mul(double value)
    {
        return new Color((int)(r * value), (int) (g * value), (int) (b * value));
    }
    public static Color1 random()
    {
        Random rand = new Random();
        int r = rand.nextInt(255);
        int g = rand.nextInt(255);
        int b = rand.nextInt(255);
        Color c = new Color(r, g, b);
        return c;
    }
    public java.awt.Color toJavaColor()
    {
        return javaColor;
    }
    public java.awt.Color toJavaColor(double t)
    {
        //if(t )
        return new java.awt.Color(r, g, b, (int) ((1 - t) * 255));
    }
    public static Color fromString(String s) throws BuildismException
    {
        try
        {
            String[] parts = s.split(",");
            return new Color(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
        }
        catch(Exception ex)
        {
            throw new BuildismException("Error parsing Vec2D value");
        }
    }
    public int getR()
    {
        return r;
    }
    public int getG()
    {
        return g;
    }
    public int getB()
    {
        return b;
    }
    public void setR(int r)
    {
        this.r = r;
        javaColor = new java.awt.Color(r, g, b);
    }
    public void setG(int g)
    {
        this.g = g;
        javaColor = new java.awt.Color(r, g, b);
    }
    public void setB(int b)
    {
        this.b = b;
        javaColor = new java.awt.Color(r, g, b);
    }

    @Override
    public String toString()
    {
        return r+","+g+","+b;
    }
    @Override
    public boolean equals(Object obj)
    {
        if(!(obj instanceof Color))
            return false;
        else if(obj == this)
            return true;
        else
        {
            Color c = (Color) obj;
            return c.r == r && c.g == g && c.b == b;
        }
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 47 * hash + this.r;
        hash = 47 * hash + this.g;
        hash = 47 * hash + this.b;
        return hash;
    }
}
*/